﻿@*@{
    List<DHQGHN.PM0.Models.Admin.MenuModel> menuList = ViewBag.Menu;
}
<ul class="page-sidebar-menu" data-auto-scroll="true" data-slide-speed="200">
    <li style="sidebar-toggler-wrapper">
        <a href="/Home">
            <span class="glyphicon glyphicon-home" style="font-size:14px; color:#fff;"></span>
        </a>
        <div class="sidebar-toggler">
        </div>
    </li>
    @foreach (var mp in menuList.Where(p => p.ParentMenuId == 0))
    {
        <li>
            <a href="@mp.MenuUrl">@mp.MenuName</a>
            @if (menuList.Count(p => p.ParentMenuId == mp.MenuId) > 0)
            {
                @:<ul>
        }

            @RenderMenuItem(menuList, mp)

            @if (menuList.Count(p => p.ParentMenuId == mp.MenuId) > 0)
            {
                @:</ul>
            }

        </li>
    }
    <li style="width:150px; text-align:center; float:right;color:#FFF">
        <span>
            @DateTime.Now.ToString("dddd, dd/MM/yyyy")
        </span>
    </li>
    <li style="width:100px; text-align:center; float:right">
        @Html.ActionLink("Logout", "Logout", "Login", null, new { style = "color:#FFF;" })
    </li>
</ul>

@helper RenderMenuItem(List<DHQGHN.PM0.Models.Admin.MenuModel> menuList, DHQGHN.PM0.Models.Admin.MenuModel mi)
{
    foreach (var cp in menuList.Where(p => p.ParentMenuId == mi.MenuId))
    {

        @:<li>
            <a href="@cp.MenuUrl">@cp.MenuName</a>

        if (menuList.Count(p => p.ParentMenuId == cp.MenuId) > 0)
        {
            @:<ul>
        }

        @RenderMenuItem(menuList, cp)
        if (menuList.Count(p => p.ParentMenuId == cp.MenuId) > 0)
        {
            @:</ul>
        }
        else
        {
            @:</li>
      }
    }
}*@


@helper RenderMenuItem(List<DHQGHN.PM0.Models.Admin.MenuModel> menuList, DHQGHN.PM0.Models.Admin.MenuModel mi)
{
    foreach (var cp in menuList.Where(p => p.ParentMenuId == mi.MenuId))
    {
        <li mid="@cp.MenuId" class="@ViewBag.ActiveMenus[cp.MenuId]">
            @*Html.ActionLink(cp.MenuName, spl[2], spl[1], routeValues: null, htmlAttributes: new { @id = "cName" })
            *@
            <a href="@cp.MenuUrl"><i class="fa fa-hdd-o"></i> @cp.MenuName</a>
        </li>
    }
}

@{
    ViewBag.ActiveMenus = ViewBag.ActiveMenus == null ? new System.Collections.Hashtable() : ViewBag.ActiveMenus;
}

<ul class="page-sidebar-menu " data-auto-scroll="true" data-slide-speed="200">
    <!-- DOC: To remove the sidebar toggler from the sidebar you just need to completely remove the below "sidebar-toggler-wrapper" LI element -->
    <li class="sidebar-toggler-wrapper">
        <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
        <div class="sidebar-toggler">
        </div>
        <!-- END SIDEBAR TOGGLER BUTTON -->
    </li>
    <li mid="0" class="start @ViewBag.ActiveMenus[0]" style="margin-top:5px;">
        <a href="@Url.Content("~/Home")">
            <i class="icon-home"></i>
            <span class="title">Trang chủ</span>
        </a>
    </li>
    @{
        //if (HttpContext.Current.User.Identity.IsAuthenticated)
        //{
            //if (Session["MenuList"] != null)
            //{
                System.Collections.Hashtable icons = new System.Collections.Hashtable();
                icons[0] = "fa fa-gears";
                icons[1] = "fa fa-sitemap";
                icons[2] = "fa fa-file-powerpoint-o";
                icons[3] = "fa fa-key";
                icons[4] = "fa fa-spinner";

                List<DHQGHN.PM0.Models.Admin.MenuModel> listMenu = ViewBag.Menu;//ViewBag.Menu;//new List<DHQGHN.PM2.Models.MenuModel>();
                if (listMenu.Count > 0)
                {
                    int iMenu = 0;
                    foreach (var mp in listMenu.Where(p => p.ParentMenuId == 0))
                    {
                        <li mid="@mp.MenuId" class="@ViewBag.ActiveMenus[mp.MenuId]">
                            <a href="@mp.MenuUrl"><i class="@icons[iMenu]"></i> <span class="title">@mp.MenuName</span> <span class="arrow"></span></a>
                            <ul class="sub-menu">
                                @RenderMenuItem(listMenu, mp)
                            </ul>
                        </li>
                        ++iMenu;
                    }
                }
            @*}*@
        @*}
        else
        {
            <li style="width:100px; text-align:center; float:right">
                @Html.ActionLink("Logout", "Logout", "Login", null, new { style = "color:#FFF;" })
            </li>
        }*@
    }
</ul>